<template>
  <div class="wf-input">
    {{ no }}
    <!-- <el-input
      v-model="innerNo"
      :disabled="true"
    /> -->
  </div>
</template>
<script>
import { mapActions } from 'vuex'
export default {
  name: 'WfNo',
  props: {
    prefix: {
      type: String,
      default: null
    },
    no: {
      type: String,
      default: null
    },
    active: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      innerNo: ''
    }
  },
  watch: {
    async active(newVal, oldVal) {
      console.log(0, newVal)
      if (!newVal) return
      this.getData()
    }
  },
  mounted() {
    if (!this.active) return
    this.getData()
    // this.userName = this.$store.state.session.user.name
  },
  methods: {
    ...mapActions('noGenerate', ['generateNoAsync']),

    async getData() {
      var no = await this.generateNoAsync(this.prefix)
      this.innerNo = no
      this.$emit('update:no', no)
    }
  }
}
</script>
